# coding: utf8
# try something like
def index(): return dict(message="hello from pdf_from_csv.py")

cvs_file_path = os.path.join(request.folder,'static','pyfpdf','examples','invoice.csv')

def import_csv():
    from gluon.contrib.pyfpdf import Template
    
    f = Template()
#    f.parse_csv(infile="/Users/christophersteel/dev/trunk/web2py/applications/uc_pdf/static/pyfpdf/examples/invoice.csv", delimiter=";", decimal_sep=",")
    f.parse_csv(infile=cvs_file_path, delimiter=";", decimal_sep=",")
    for v in f.fields.elements():
        v['align']=  {'I':'L','D':'R','C':'C','':''}.get(v['align'], 'L')
        v['pdf_template_id'] = 1
        db.pdf_element.insert(**v)


#simple-csv-invoice.txt
